VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "CFaceIndexCreator"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Public Event OnProcess(ByVal Index As Long)
Public Event OnFinish()

Private WithEvents Drv As Timer
Attribute Drv.VB_VarHelpID = -1

Private mvarStartIndex As Long
Private mvarFinishIndex As Long
Private mvarCurrentIndex As Long

Public Property Let StartIndex(ByVal Index As Long)
    mvarStartIndex = Index
End Property

Public Property Get StartIndex() As Long
    StartIndex = mvarStartIndex
End Property

Public Property Let FinishIndex(ByVal Index As Long)
    mvarFinishIndex = Index
End Property

Public Property Get FinishIndex() As Long
    FinishIndex = mvarFinishIndex
End Property

Public Property Let CurrentIndex(ByVal Index As Long)
    mvarCurrentIndex = Index
End Property

Public Property Get CurrentIndex() As Long
    CurrentIndex = mvarCurrentIndex
End Property

Public Property Set Trigger(RHS As Timer)
    Set Drv = RHS
End Property

Public Sub Initialize()
    Drv.Enabled = False
    Drv.Interval = 1
    CurrentIndex = StartIndex
End Sub

Public Sub Continue()
    Drv.Enabled = True
End Sub

Public Sub Pause()
    Drv.Enabled = False
End Sub

Public Sub Stop_()
    Drv.Enabled = False
    Call Initialize
End Sub

Public Sub MoveNext()
    CurrentIndex = CurrentIndex + 1
End Sub

Private Sub Drv_Timer()
    Drv.Enabled = False
    
    If IsFinish Then
        RaiseEvent OnFinish
    Else
        RaiseEvent OnProcess(CurrentIndex)
    End If
End Sub

Private Function IsFinish() As Boolean
    If CurrentIndex > FinishIndex Then
        IsFinish = True
    Else
        IsFinish = False
    End If
End Function
